{% load i18n %}

{% if page.paginator.count > 0 %}
{% load navigation_tags %}
{% with page_param=prefix|add:'page' %}
{% with page_size_param=prefix|add:'page_size' %}
<div class="pull-left pagination  pagination-sm">
    {% blocktrans with start_index=page.start_index end_index=page.end_index count=page.paginator.count %}
    Showing entries {{ start_index }} to {{ end_index }} of {{ count }}
    {% endblocktrans %}
</div>

<nav class="pull-right" aria-label="Pagination navigation">
    <ul class="pagination pagination-sm">
            {% if page.has_other_pages %}
                {% for num in page|paginate:5 %}
                    <li {% if num.is_current %}class="active"{% endif %}>
                        {% if num.page_number %}
                            <a href="?{% url_replace request page_param num.page_number %}" aria-label="{% trans 'Page' %} {{ num.display }}"> {{ num.display }}</a>
                        {% else %}
                            <a role="presentation" aria-disabled="true" tabindex="-1">{{ num.display }}</a>
                        {% endif %}
                    </li>
                {% endfor %}
            {% endif %}
            {% if page_size %}
                <li>
                    <!-- Split button -->
                    &nbsp;
                    <div class="btn-group">
                        <button data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="{% trans 'Page size selector' %}" id="pageSizeDropdown" class="btn-sm btn-secondary dropdown-toggle" type="button">
                            {% trans "Page Size" %}
                            <span class="caret"></span>
                            <span class="sr-only">{% trans "Toggle Dropdown" %}</span>
                        </button>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="pageSizeDropdown">
                            <li role="presentation"><a href="?{% url_replace request page_size_param 25 %}" aria-label="{% trans '25 items per page' %}" role="menuitem">25</a></li>
                            <li role="presentation"><a href="?{% url_replace request page_size_param 50 %}" aria-label="{% trans '50 items per page' %}" role="menuitem">50</a></li>
                            <li role="presentation"><a href="?{% url_replace request page_size_param 75 %}" aria-label="{% trans '75 items per page' %}" role="menuitem" >75</a></li>
                            <li role="presentation"><a href="?{% url_replace request page_size_param 100 %}" aria-label="{% trans '100 items per page' %}" role="menuitem">100</a></li>
                            <li role="presentation"><a href="?{% url_replace request page_size_param 150 %}" aria-label="{% trans '150 items per page' %}" role="menuitem">150</a></li>
                            {% if page.paginator.count > 250 %}
                                <li role="presentation"><a href="?{% url_replace request page_size_param 250 %}" aria-label="{% trans '250 items per page' %}" role="menuitem" >250</a></li>
                            {% endif %}
                        </ul>
                    </div>
                </li>
            {% endif %}
        </ul>
    </nav>
{% endwith %}
{% endwith %}
{% endif %}
